using System.ComponentModel.DataAnnotations.Schema;
using System.Data.Entity.ModelConfiguration;
using SCS.Common.Models;
namespace SCS.DAL.Mapping
{
    public class ClassMap : EntityTypeConfiguration<Class>
    {
        public ClassMap()
        {
            // Primary Key
            this.HasKey(t => t.classID);

            // Properties
            this.Property(t => t.classID)
                .HasDatabaseGeneratedOption(DatabaseGeneratedOption.None);

            // Table & Column Mappings
            this.ToTable("Classes");
            this.Property(t => t.classID).HasColumnName("classID");
            this.Property(t => t.startDate).HasColumnName("startDate");
            this.Property(t => t.teacherID).HasColumnName("teacherID");

            // Relationships
            this.HasOptional(t => t.Teacher)
                .WithMany(t => t.Classes)
                .HasForeignKey(d => d.teacherID);

        }
    }
}
